/**
 * XMLFlightGenerator.java
 * Dec 28, 2009
 */
package com.dlplay.flightinfo.presentation;

import org.w3c.dom.Document;
import org.w3c.dom.Element;

import com.dlplay.flightinfo.data.Airport;
import com.dlplay.flightinfo.data.FlightInfo;

/**
 * @author zhao yu
 *
 */
public class XMLAirportGenerator implements XMLGenerator {

	private Airport data;
	public XMLAirportGenerator(Airport airport) {
		data = airport;
	}

	/* (non-Javadoc)
	 * @see com.dlplay.flightinfo.server.XMLGenerator#generate(org.w3c.dom.Document)
	 */
	@Override
	public void generate(Document document) {
		Element eltItem = document.createElement("Airport");
		Element eltNum = document.createElement("Name");
		Element eltStatus = document.createElement("Wether");
		eltNum.appendChild(document.createTextNode(data.getName()));
		eltStatus.appendChild(document.createTextNode(data.getWeather().getTemperatureHigh().toString()));
		eltItem.appendChild(eltNum);
		eltItem.appendChild(eltStatus);
		document.appendChild(eltItem);
		document.normalizeDocument();
	}

}
